public class DBQuery implements IDBQuery {
    public DBQuery(){
        try {
            Thread.sleep(1000);
            System.out.println("线程运行结束");
        }catch (InterruptedException e){
            e.printStackTrace();
        }
    }
    @Override
    public String request(){
        return "return string";
    }
}
//写一个代理类 代替DBQuery的位置
class DBQueryProxy implements IDBQuery{
    private  DBQuery real=null;
    @Override
    public String request() {
        System.out.println("123");
        if (real==null){
            real =new DBQuery();
        }
        return real.request();
    }
}
class Main{
    public static void main(String[] args) {
        IDBQuery q=new DBQueryProxy();
        q.request();
    }
}